//
//  PaymentDetailsViewModel.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/6.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "PaymentDetailsViewModel.h"
#import "PaymentDetailsTableViewCell.h"
#import "NoDataFootTableViewHeaderFooterView.h"

@interface PaymentDetailsViewModel ()<UITableViewDelegate, UITableViewDataSource>
{
    UITableView *selfTableView;
}

@end

@implementation PaymentDetailsViewModel

- (instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView
{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        tableView.sectionFooterHeight = 0.0;
        tableView.sectionHeaderHeight = 0.0;
        [tableView registerClass:[NoDataFootTableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"NoDataFootTableViewHeaderFooterView"];
        [superView addSubview:tableView];
        selfTableView = tableView;
    }
    return self;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return kHeightProportion_In_iPhoneTriploid(10);
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    NoDataFootTableViewHeaderFooterView *footer = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
    return footer;
}

#pragma mark - tableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 9;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kHeightProportion_In_iPhoneTriploid(117);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PaymentDetailsTableViewCell *detailCell = [PaymentDetailsTableViewCell cellWithTableView:tableView];
    if (indexPath.row % 2 == 0) {
        NSString *str = @" ¥3450";
        //        moneyLab.text = @"¥3030";
        NSAttributedString *att = [GLGWLabel bllChangeStr:str changewithStr:@"¥" changeColoer:[UIColor colorWithHexString:@"#5DC061"] withFont:SYSTEMFONT(12)];
        NSMutableAttributedString *att2 = [GLGWLabel bllChangeStr:@"+" changewithStr:@"+" changeColoer:[UIColor colorWithHexString:@"#5DC061"] withFont:SYSTEMFONT(14)];
        [att2 appendAttributedString:att];
        detailCell.moneyLab.attributedText = att2;
    }
    return detailCell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.BlockSelet) {
        self.BlockSelet(indexPath);
    }
}

@end
